package org.caenv.interpreter.pojo.instructions;

import java.util.Map;

public class GoTo implements Instruction {

    private String nameState;

    public static final String ATTR_STATE = "state";

    @Override
    public boolean build(Map<String, String> attributes) {
        if(attributes == null || !attributes.containsKey(ATTR_STATE)){
            return false;
        }else{
            this.nameState = attributes.get(ATTR_STATE);
            return true;
        }
    }

    @Override
    public boolean execute(ExecutionPlan executionPlan) {
        return executionPlan.setStateByName(nameState);
    }

}
